package com.bdqn.qnnews.rest.exception;

import com.bdqn.qnnews.common.base.ResultCode;

/**
 * 自定义项目异常父类
 * @author xlzhang
 */
public class ApplicationException extends RuntimeException {
    /**
     * 统一的异常信息枚举类
     */
    private final ResultCode resultCode;

    public ApplicationException(String message) {
        super(message);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(Throwable cause) {
        super(cause);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(String message, Throwable cause) {
        super(message, cause);
        this.resultCode = ResultCode.SERVER_ERROR;
    }

    public ApplicationException(ResultCode resultCode) {
        super(resultCode.getErrorMessage());
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, String message) {
        super(message);
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, Throwable cause) {
        super(cause);
        this.resultCode = resultCode;
    }

    public ApplicationException(ResultCode resultCode, String message, Throwable cause) {
        super(message, cause);
        this.resultCode = resultCode;
    }

    public ResultCode getResultCode() {
        return resultCode;
    }
}